import { http } from '@/utils/axios/init'

// 相同前缀
const prefix = '/ctms/Rest/sop/speed'
const prefix_phase = '/ctms/Rest/sop/phase'
const prefix_task = '/ctms/Rest/sop/task'

// 查询进度模板
export function PTlistByPage(data) {
  return http.request({
    url: `${prefix}/listByPage`,
    method: 'get',
    params: data
  })
}

// 复制模板
export function PTCopy(data) {
  return http.request({
    url: `${prefix}/copy`,
    method: 'post',
    params: data
  })
}

// 运维端新增模板
export function speedAddSave(data) {
  return http.request({
    url: `${prefix}/save`,
    method: 'post',
    params: data
  })
}

// 查询模板详情
export function PTgetById(data) {
  return http.request({
    url: `${prefix}/getById`,
    method: 'get',
    params: data
  })
}

export function PTlist(params) {
  return http.request({
    url: `${prefix}/list`,
    method: 'get',
    params
  })
}
// 新增模板
export function PTchooseTemplate(data) {
  return http.request(
    {
      url: `${prefix}/chooseTemplate`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '模板添加成功'
    }
  )
}

// 编辑模板
export function PTupdate(data) {
  return http.request(
    {
      url: `${prefix}/update`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '模板编辑成功'
    }
  )
}

// 更新模板状态
export function PTupdateStatus(data) {
  return http.request(
    {
      url: `${prefix}/updateStatus`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '状态已变更'
    }
  )
}

// 删除模板
export function PTDdelete(data) {
  return http.request(
    {
      url: `${prefix}/delete`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '删除成功'
    }
  )
}

// SOP 新增阶段
export function sopPhaseSave(data) {
  return http.request(
    {
      url: `${prefix_phase}/save`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '阶段添加成功'
    }
  )
}

// SOP 删除阶段
export function sopDelPhase(params) {
  return http.request(
    {
      url: `${prefix_phase}/delete`,
      method: 'post',
      params
    },
    {
      successMessageText: '阶段删除成功'
    }
  )
}

// SOP 复制阶段
export function sopCopyPhase(params) {
  return http.request(
    {
      url: `${prefix_phase}/copy`,
      method: 'post',
      params
    },
    {
      successMessageText: '阶段复制成功'
    }
  )
}

// SOP 编辑阶段
export function sopUpdatePhase(params) {
  return http.request(
    {
      url: `${prefix_phase}/update`,
      method: 'post',
      params
    },
    {
      successMessageText: '阶段名称修改成功'
    }
  )
}

// SOP 阶段排序
export function sopPhaseChangeOrder(params) {
  return http.request({
    url: `${prefix_phase}/changeOrder`,
    method: 'post',
    params
  })
}

// SOP 新增任务
export function sopTaskSave(data) {
  return http.request(
    {
      url: `${prefix_task}/save`,
      method: 'post',
      params: data
    },
    {
      successMessageText: '任务添加成功'
    }
  )
}

// SOP 编辑任务是否需要流程
export function updateSopFlowRequired(params) {
  return http.request({
    url: `${prefix_task}/updateFlowRequired`,
    method: 'post',
    params
  })
}

// SOP 编辑任务是否需要文件清单
export function updateSopFileRequired(params) {
  return http.request({
    url: `${prefix_task}/updateFileRequired`,
    method: 'post',
    params
  })
}

//编辑任务是否需要表单
export function updateSopFormRequired(params) {
  return http.request({
    url: `${prefix_task}/updateFormRequired`,
    method: 'post',
    params
  })
}

// SOP 任务详情
export function sopTaskInfo(taskId) {
  return http.request({
    url: `${prefix_task}/getById`,
    method: 'get',
    params: { taskId }
  })
}

// SOP 查询前置任务
export function sopGetFrontTaskList(params) {
  return http.request({
    url: `${prefix_task}/getFrontTaskList`,
    method: 'get',
    params
  })
}

// SOP 编辑任务
export function sopTaskUpdate(params) {
  return http.request(
    {
      url: `${prefix_task}/update`,
      method: 'post',
      params
    },
    {
      successMessageText: '任务修改成功'
    }
  )
}

// SOP 复制任务
export function sopTaskCopy(params) {
  return http.request(
    {
      url: `${prefix_task}/copy`,
      method: 'post',
      params
    },
    {
      successMessageText: '任务复制成功'
    }
  )
}

// SOP 删除任务
export function sopDelTask(params) {
  return http.request(
    {
      url: `${prefix_task}/delete`,
      method: 'post',
      params
    },
    {
      successMessageText: '任务删除成功'
    }
  )
}

//编辑进度模板中的文件夹信息
export function updateFolder(params) {
  return http.request({
    url: `${prefix}/updateFolder`,
    method: 'post',
    params
  })
}
